package top.hundreds.oasys.bean.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum EventType {

    SICK_LEAVE(0, "病假"),
    PERSONAL_LEAVE(1, "事假"),
    PUBLIC_LEAVE(2, "公假"),
    MATERNITY_LEAVE(3, "产假"),
    FUNERAL_LEAVE(4, "丧假"),
    ANNUAL_LEAVE(5, "年假"),
    REIMBURSEMENT(6, "报销"),
    PROCUREMENT(7, "采购"),
    ITEMS_LEASE(8, "物品租借"),
    PERSONNEL_CHECK(9, "入职审批"),
    PROJECT_CREATE(10, "立项审批");

    @JsonValue
    @EnumValue
    private final Integer value;

    private final String label;

    public static EventType formValue(Object o) {
        if (o != null) {
            for (EventType eventType : values()) {
                if (eventType.getValue().equals(o)) {
                    return eventType;
                }
            }
        }
        return null;
    }

    public static EventType formLabel(Object o) {
        if (o != null) {
            for (EventType eventType : values()) {
                if (eventType.getLabel().equals(o)) {
                    return eventType;
                }
            }
        }
        return null;
    }
}
